<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<jsp:useBean id="carManager" class="manager.CarManager" scope="page" />
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<link rel="stylesheet" type="text/css" href="system/css/main.css" />
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Cars</title>
</head>
<body>
	<div id="header">
		<div id="user">
			Hello
			<c:if test="${empty username }">
			Guest
			</c:if>
			<c:if test="${!empty username }">
				<a href="user.jsp">${username.username}</a>
				<a href="/PRIS/logoutServlet">Logout</a>
			</c:if>
		</div>
		<div id="logo">
			<a href="home.jsp"><img src="system/images/logo.jpg"></a>
		</div>
		<div id="navigation">
			<ul>
				<li><a href="home.jsp">Home</a></li>
				<li><a href="ads.jsp">Cars</a></li>
				<c:if test="${!empty username }">
					<li><a href="addAd.jsp">Add new Car</a></li>
				</c:if>
				<li><a href="search.jsp">Search</a></li>
				<li><a href="last24hAds.jsp">Last 24h ads</a></li>
				<li><a href="mostUsed.jsp">Most used</a></li>
			</ul>
		</div>
	</div>

	<div id="content">
		<div id="test">Cars page</div>
		<table align="center" border="1">
			<tr>
				<th>Car brand</th>
				<th>Car model</th>
				<th>Car price</th>
				<th>Car fuel type</th>
				<th>Car year</th>
				<th>Car power</th>
				<th>Car kilometers</th>
				<th>Car details</th>
			</tr>
			<c:if test="${empty cars}">
				<c:forEach var="car" items="${carManager.getAllCars()}">
					<tr>
						<td>${car.brand }</td>
						<td>${car.model }</td>
						<td>${car.price }</td>
						<td>${car.fuelType }</td>
						<td>${car.year }</td>
						<td>${car.power }</td>
						<td>${car.kilometers }</td>
						<td><a href="/PRIS/DetailCarServlet?id=${car.id}">Details</a></td>
					</tr>
				</c:forEach>
			</c:if>
			<c:if test="${!empty cars}">
				<c:forEach var="car" items="${cars}">
					<tr>
						<td>${car.brand }</td>
						<td>${car.model }</td>
						<td>${car.price }</td>
						<td>${car.fuelType }</td>
						<td>${car.year }</td>
						<td>${car.power }</td>
						<td>${car.kilometers }</td>
						<td><a href="/PRIS/DetailCarServlet?id=${car.id}">Details</a></td>
					</tr>
				</c:forEach>
				<%session.removeAttribute("cars");%> 
			</c:if>
		</table>
		<a href="last24hAds.jsp">Last 24h ads</a>
	</div>

	<div id="footer">
		<div id="copyright">Copyright © 2013</div>
	</div>
</body>
</html>